package com.xiang.reggie.common;

/**
 *  基于ThreadLocal封装工具类，用户保存和获取当前登录用户id
 *
 * @author 半山居雾
 * @date 2022/12/15 10:13
 */
public class BaseContext {

    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();


    /**
     * 设置当前id
     *
     * @param id id
     */
    public static void setCurrentId(Long id) {
        threadLocal.set(id);
    }

    /**
     * 得到当前id
     *
     * @return {@code Long}
     */
    public static Long getCurrentId() {
        return threadLocal.get();
    }


}
